package algorithm.tree;

/**
 * 红黑树结点定义
 *
 * @author: fengpeng
 * @date: 2019/1/23 下午4:41
 */
public class RedBlackNode<T extends Comparable<? super T>> {

    /**
     * 颜色：0 是红色，1是黑色
     */
    int color;

    /**
     * 节点数据
     */
    T date;

    /**
     * 左子树
     */
    RedBlackNode<T> left;

    /**
     * 右子树
     */
    RedBlackNode<T> right;

    /**
     * 右子树
     */
    RedBlackNode<T> parent;

    public RedBlackNode(int color, T date, RedBlackNode<T> left, RedBlackNode<T> right, RedBlackNode<T> parent) {
        this.color = color;
        this.date = date;
        this.left = left;
        this.right = right;
        this.parent = parent;
    }

    public RedBlackNode() {
        // 默认是黑色
        this.color = Color.BLACK.getCode();
        this.date = null;
        this.left = null;
        this.right = null;
        this.parent = null;
    }
}
